clear all
set more off

**** GLOBALS *****;
global 	InputFile ${dat}\HSV_repdata.dta
global 	OutputDir ${res}
*********************;


use ${InputFile} , clear



//levels of pre and postgov inc
gen pregovinc = max(redpregovinc - tot_deduction + 0.5*fica,0)
gen dispinc = max(reddispinc - tot_deduction + 0.5*fica + hwdpvpengain1,0)

//logs of pre and postgov inc
replace lpregovinc = log(redpregovinc - tot_deduction + 0.5*fica)
replace ldispinc = log(reddispinc - tot_deduction + 0.5*fica + hwdpvpengain1)

qui reg ldispinc lpregovinc
keep if e(sample)




//do  test of appropriateness of log linearization

poisson dispinc lpregovinc, robust
predict fit, ir

gen lfit=log(fit)
gen lscore=log((dispinc-fit)^2)
 
reg lscore lfit
sca b=_b[lfit]
sca se=_se[lfit]
test lfit=2

mat A=[b,se,r(F),r(p)]
putexcel set "${OutputDir}\Log_Lin_Test", sheet(1) replace
putexcel A1=matrix(A)








